<?php

namespace common\models\datas;

use webback\models\data\Website;
use Yii;
use yii\helpers\ArrayHelper;
use yii\behaviors\TimestampBehavior;
use yii\db\ActiveRecord;
use common\components\behaviors\UpdateCacheBehavior;


class ReplyMsg extends \common\components\bases\BaseModel
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%reply_msg}}';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['type'], 'required'],
            [['type','text','img_url','url','description','wechat_media_id','music_url','hqmusic_url'], 'string'],
            [['text','img_url','url','description'],'required','when'=>function($model){
                return $model->type=='news';
            }],
            [['text','description'],'required','when'=>function($model){
                return $model->type=='text'||$model->type=='video';
            }],
            [['wechat_media_id'],'required','when'=>function($model){
                return $model->type=='image'||$model->type=='voice'||$model->type=='video';
            }],
            [['music_url'],'required','when'=>function($model){
                return $model->type=='music';
            }],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => Yii::t('common', '自增id'),
            'type' => Yii::t('common', '消息类型'),
            'text' => Yii::t('common', '回复内容'),
            'img_url' => Yii::t('common', '图片链接'),
            'url' => Yii::t('common', '图文链接'),
            'description' => Yii::t('common', '图文描述'),
            'wechat_media_id' => Yii::t('common', '媒体资源id'),
            'music_url' => Yii::t('common', '音乐链接'),
            'hqmusic_url' => Yii::t('common', '高品质音乐url'),
        ];
    }
}